package com.gxa.saas.admin.controller;


import com.gxa.saas.admin.entiry.COVO;
import com.gxa.saas.admin.entiry.GBOrderVO;
import com.gxa.saas.admin.service.GBOrderService;
import com.gxa.saas.core.common.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@Api("商品管理模块")
@RestController
@RequestMapping("/GBOrder")
public class GBOrderController {

    @Autowired
    private GBOrderService service;

    @ApiOperation("全部订单接口")
    @GetMapping("/Order")
    public JsonResult getAll(){
        List<GBOrderVO> list = service.queryAllOrder();
        JsonResult js=new JsonResult();
        js.setCode("200");
        js.setMsg("查询成功");
        if(list.size()>0){
            js.setCode("200");
            js.setMsg("查询成功");
        }else {
            js.setCode("201");
            js.setMsg("查询成功,但是无对应数据");
        }
        js.setData(list);
        return js;
    }

    @ApiOperation("订单条件查询接口")
    @ResponseBody
    @PostMapping("/condition")
    public JsonResult condition(COVO covo){
        List<GBOrderVO> list = service.queryAllByCon(covo);
        JsonResult js=new JsonResult();
        if(list.size()>0){
            js.setCode("200");
            js.setMsg("查询成功");
        }else {
            js.setCode("201");
            js.setMsg("查询成功,但是无对应数据");
        }
        js.setData(list);
        return js;
    }

    @ApiOperation("订单详情接口")
    @ResponseBody
    @PostMapping("/details")
    public JsonResult details(Integer id){
        COVO covo=new COVO();
        covo.setId(id);
        List<GBOrderVO> list = service.queryAllByCon(covo);
        JsonResult js=new JsonResult();
        if(list.size()>0){
            js.setCode("200");
            js.setMsg("查询成功");
        }else {
            js.setCode("201");
            js.setMsg("查询成功,但是无对应数据");
        }
        js.setData(list);
        return js;
    }
}
